package com.zsy.mapper;

import com.zsy.pojo.Electric_Power;
import com.zsy.pojo.RegionInfo;
import com.zsy.pojo.month;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface region_Mapper {

    @Select("SELECT * FROM region_info;")
    List<RegionInfo> getName();

    @Select("SELECT * FROM power_consumption WHERE region_name = #{regionName} AND load_name = #{loadName} AND record_date = #{recordData};")
    List<Electric_Power> SearchInfo(String regionName, int loadName, LocalDate recordData);

    @Select("SELECT SUM(power_consumption) FROM power_consumption WHERE region_name = #{regionName} AND load_name = #{loadName} AND record_date = #{recordData};")
    double TotalElectric(String regionName, int loadName, LocalDate recordData);

    @Select("SELECT COUNT(*) AS total_count FROM region_info;")
    int TotalRegion();

    @Select("SELECT round(avg(temperature),2) FROM power_consumption WHERE region_name = #{regionName} AND load_name = #{loadName} AND record_date = #{recordData};")
    double AvgTemperature(String regionName, int loadName, LocalDate recordData);

    @Select("SELECT * FROM power_consumption WHERE region_name = #{regionName} AND record_date = #{recordData};")
    List<Electric_Power> SearchInfo_no_load_name(String regionName, LocalDate recordData);

    @Select("SELECT * FROM monthly_power_2023;")
    List<month> monthly_power_2023();

    @Select("SELECT * FROM monthly_power_2024;")
    List<month> monthly_power_2024();
}
